package ch.janotta.slawo.ultraquest.types;

public class Item {
  private String name;
  private ItemQuality quality;
  private int armorValue;
  private int closeCombatValue;
  private int rangedCombatValue;
  private int goldValue;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public ItemQuality getQuality() {
    return quality;
  }

  public void setQuality(ItemQuality quality) {
    this.quality = quality;
  }

  public int getArmorValue() {
    return armorValue;
  }

  public void setArmorValue(int armorValue) {
    this.armorValue = armorValue;
    calculateGoldValue(armorValue);
  }

  public int getCloseCombatValue() {
    return closeCombatValue;
  }

  public void setCloseCombatValue(int closeCombatValue) {
    this.closeCombatValue = closeCombatValue;
    calculateGoldValue(closeCombatValue);
  }

  public int getRangedCombatValue() {
    return rangedCombatValue;
  }

  public void setRangedCombatValue(int rangedCombatValue) {
    this.rangedCombatValue = rangedCombatValue;
    calculateGoldValue(rangedCombatValue);
  }

  public boolean isArmor() {
    return armorValue > 0;
  }

  public boolean isCloseCombatWeapon() {
    return closeCombatValue > 0;
  }

  public boolean isRangedCombatWeapon() {
    return rangedCombatValue > 0;
  }

  public int getGoldValue() {
    return goldValue;
  }

  public void setGoldValue(int goldValue) {
    this.goldValue = goldValue;
  }

  private void calculateGoldValue(int baseValue) {
    if (this.quality == ItemQuality.COMMON) {
      this.goldValue = baseValue * 10;
    } else if (this.quality == ItemQuality.EXCELENT) {
      this.goldValue = baseValue * 30;
    } else if (this.quality == ItemQuality.MASTER) {
      this.goldValue = baseValue * 100;
    }
  }
}
